
package com.nhc.model;

import zuo.biao.library.base.BaseModel;

//http://www.cnblogs.com/naaoveGIS/p/4230656.html
//七参数法（包括布尔莎模型，一步法模型，海尔曼特等）是解决此问题的比较严密和通用的方法。
//        其涉及到的七个参数为：X平移，Y平移，Z平移，X旋转，Y旋转，Z旋转，尺度变化K。
//        此七个参数可以通过在需要转化的区域里选取3个以上的转换控制点对而获取。
//
//如果区域范围不大，最远点间的距离不大于30Km(经验值)，这可以用三参数（莫洛登斯基模型），即X平移，Y平移，Z平移，
//        而此时将X旋转，Y旋转，Z旋转，尺度变化K视为0。所以三参数只是七参数的一种特例。三参数只需通过1个控制点对就能获取
//https://wenku.baidu.com/view/9ece8f2e7275a417866fb84ae45c3b3567ecddaa.html -- 7参数提供

//DA为两种坐标系统椭球长半轴差值，DF为两种坐标系统椭球扁率的差值
//一旦确定你所使用的坐标系统，DA，DF即作为固定值存在，
// 若使用西安80，DA=-3，DF=-0.0000000025(GPS中输入显示0)
//BJ54 DA=-108， DF=0.00480795

public class TransParaSeven extends BaseModel {

    private static final long serialVersionUID = 1L;

    //    DXR，DYR，DZR指的是沿着X,Y,Z三个轴旋转的角度偏移量；
//    DX，DY，DZ是X,Y,Z三个轴的坐标偏移量；
//    m_dbScale指的是比例系数
//BJ54坐标系 :属参心坐标系 长轴6378245m 短轴6356863 扁率1/298.3
//XIAN80坐标系 :属参心坐标系 长轴6378140m 短轴6356755 扁率1/298.25722101
//WGS84坐标系 :属地心坐标系 长轴6378137.000m 短轴6356752.314 扁率1/298.257223563
//CGCS2000坐标系 :属地心坐标系 长轴6378137.000m 短轴6356752.31414  扁率f = 1/ 298.257222101
    //    public static final String[] COORD_0 = {"WGS84", "BJ54", "XA80", "CGCS2000", "自定义"};
    public int type = 0;//coord_0--TransParaSevenFileHandle.getInstance().m_ElipsInfoList  -- 0-WGS84

    public double DX = 0;
    public double DY = 0;
    public double DZ = 0;
    private double DA = -3;//用来修正长半轴aAxis
    private double DF = 0;//用来修正离心率flat

    public double aAxis = 6378137;//长轴
    public double scale = 0;

    public double flat = 1 / 298.257223563D;//离心率
    //aAxis = 6378137 - DA;
    //flat = 1 / 298.257223563 - DF／10000;

    //基本不用
    public double DXR = 0;
    public double DYR = 0;
    public double DZR = 0;

    double[] eSparam = {298.257223563, 6378137.0, 0, 0, 0, 0, 0, 0, 0};
    
    public TransParaSeven() {
        //default

    }

    public TransParaSeven(int type, double[] eparam) {
        this.type = type;
        if (eparam != null && eparam.length == eSparam.length) {
            eSparam = eparam;
        }
        
        reset();
    }

    //用户是否修改过
    public boolean isChange() {
        if (type >0 && type < m_ElipsInfoList.length) {
            eSparam = m_ElipsInfoList[type];
        } else {
            return true;
        }

        if (flat == (double) (1 / eSparam[0]) && aAxis == eSparam[1] && DX == eSparam[2] && DY == eSparam[3]
                && DZ == eSparam[4] && DXR == eSparam[5] && DYR == eSparam[6]
                && DZR == eSparam[7] && scale == eSparam[8]) {
            return false;
        }

        return true;
    }

    public void reset() {
        if (type >=0 && type < m_ElipsInfoList.length) {
            eSparam = m_ElipsInfoList[type];
        }

        flat = (double) (1 / eSparam[0]);
        aAxis = eSparam[1];

        DA = 6378137 - aAxis;
        DF = ((1 / 298.257223563D) - flat) * 10000.0D;

        DX = eSparam[2];
        DY = eSparam[3];
        DZ = eSparam[4];
        DXR = eSparam[5];
        DYR = eSparam[6];
        DZR = eSparam[7];
        scale = eSparam[8];
    }

    public double getDA() {
        return DA;
    }

    public double getDF() {
        return DF;
    }

    public void setDA(double DA) {
        this.DA = DA;
        aAxis = 6378137 - DA;
    }

    public void setDF(double DF) {
        this.DF = DF;
        flat = (1 / 298.257223563D) - (DF / 10000.0D);
    }

    @Override
    protected boolean isCorrect() {//根据自己的需求决定，也可以直接 return true
        return id > 0;// && StringUtil.isNotEmpty(phone, true);
    }

//0-离心率
//1-长半轴
//2-DX
//3-DY
//4-DZ
//5-DXR
//6-DYR
//7-DZR
//8-scale
    public final static double m_ElipsInfoList[][] = new double[][]{
            {298.257223563, 6378137.0, 0, 0, 0, 0, 0, 0, 0},//WGS84
            {298.3, 6378245, 0, 0, 0, 0, 0, 0, 0},//BJ54
            {298.257223563, 6378140, 0, 0, 0, 0, 0, 0, 0},//XA80
            {298.257222101, 6378137.0, 0, 0, 0, 0, 0, 0, 0},//CGCS2000_
            {298.257223563, 6378137.0, 0, 0, 0, 0, 0, 0, 0},//USER

            {293.465, 6378249.145, -162, -12, 206, 0, 0, 0, 0},//ADIND_
            {298.3, 6378245.000, -43, -163, 45, 0, 0, 0, 0},//AFG_
            {297.0, 6378388.0, -150, -251, -2, 0, 0, 0, 0},//AINELABD_
            {294.9786982, 6378206.4, -5, 135, 172, 0, 0, 0, 0},//ALASK_
            {293.465, 6378249.145, -143, -90, -294, 0, 0, 0, 0},//ARC50_
            {293.465, 6378249.145, -160, -8, -300, 0, 0, 0, 0},//ARC60_
            {297.0, 6378388.0, 114, -116, -333, 0, 0, 0, 0},//ASTROB4_
            {298.25, 6378160.0, (float) -119.353, (float) -48.301, (float) 139.484, -0.415, -0.260, -0.437, 0.613},//AUS66_
            {298.25, 6378160.0, (float) -117.763, (float) -51.51, (float) 139.061, -0.292, -0.443, -0.277, 0.191},//AUS84_
            {297.0, 6378388.0, 307, 304, -318, 0, 0, 0, 0},//BOGOT_

            {299.15281285, 6377397.155, -384, 664, -48, 0, 0, 0, 0},  //BUKIT_
            {297.0, 6378388.0, -104, -129, 239, 0, 0, 0, 0},//CAMP_
            {297.0, 6378388.0, -148, 136, 90, 0, 0, 0, 0},//CAMPO_
            {294.9786982, 6378206.4, -10, 158, 187, 0, 0, 0, 0},//CANAD_
            {293.465, 6378249.145, -136, -108, -292, 0, 0, 0, 0},//CAPE_
            {293.465, 6378249.145, (float) -266.112, (float) 7.984, (float) 443.699, 0, 0, 0, 0},//CARTH_
            {294.9786982, 6378206.4, -6, 127, 192, 0, 0, 0, 0},//CENAM_
            {297.0, 6378388.0, 175, -38, 113, 0, 0, 0, 0},//CHATH_
            {297.0, 6378388.0, -134, 229, -29, 0, 0, 0, 0},//CHUAA_
            {297.0, 6378388.0, -206, 172, -6, 0, 0, 0, 0},//CORRE_

            {297.0, 6378388.0, -104, -101, -140, 0, 0, 0, 0},//CYPRU_
            {299.15281285, 6377397.155, -377, 681, -50, 0, 0, 0, 0},   //DJAKA_
            {297.0, 6378388.0, 230, -199, -752, 0, 0, 0, 0},//DOS1968_
            {299.15281285, 6377397.155, (float) 565.04, (float) 49.91, (float) 465.84, 0.409394, -0.35971, 1.868491, -4.07720000006329},  //DTCH_
            {297.0, 6378388.0, 211, 147, 111, 0, 0, 0, 0},//EASTER_
            {297.0, 6378388.0, -130, -117, -151, 0, 0, 0, 0},//EGYPT_
            {297.0, 6378388.0, -87, -98, -121, 0, 0, 0, 0},//EUROP_
            {297.0, 6378388.0, -87, -96, -120, 0, 0, 0, 0},//EUR50_
            {297.0, 6378388.0, -86, -98, -119, 0, 0, 0, 0},//EUR79_
            {297.0, 6378388.0, -78, -231, -97, 0, 0, 0, 0},//FINNISH NAUTICAL

            {293.466021294, 6378249.2, -168, -60, 320, 0, 0, 0, 0},//FRENC_
            {297.0, 6378388.0, -133, -321, 50, 0, 0, 0, 0},//GANDA_
            {297.0, 6378388.0, 84, -22, 209, 0, 0, 0, 0},//GEO49_
            {300.5491378, 6377973.42, 0, 0, 0, 0, 0, 0, 0},//GHANA_
            {294.9786982, 6378206.4, -100, -248, 259, 0, 0, 0, 0},//GUAM_
            {299.15281285, 6377397.155, -403, 684, 41, 0, 0, 0, 0}, //GUNSG_
            {297.0, 6378388.0, 252, -209, -751, 0, 0, 0, 0},//GUX1ASTRO
            {297.0, 6378388.0, -333, -222, 114, 0, 0, 0, 0},//HERAT_
            {297.0, 6378388.0, -73, 46, -86, 0, 0, 0, 0},//HJORS_
            {297.0, 6378388.0, -156, -271, -189, 0, 0, 0, 0},//HK_

            {297.0, 6378388.0, -634, -549, -201, 0, 0, 0, 0},//HUTZU_
            {300.8017, 6377276.34518, 214, 836, 303, 0, 0, 0, 0},//INDA_
            {300.8017, 6377276.34518, 289, 734, 257, 0, 0, 0, 0},//INDM_
            {297.0, 6378388.0, -117, -132, -164, 0, 0, 0, 0},//IRAN_
            {299.3249646, 6377340.189, 506, -122, 611, 0, 0, 0, 0},//IRELA_
            {297.0, 6378388.0, 191, -77, -204, 0, 0, 0, 0},//JOHNSTON_
            {300.8017, 6377276.34518, -97, 787, 86, 0, 0, 0, 0},//KANDAWALA_
            {297.0, 6378388.0, 145, -187, 103, 0, 0, 0, 0},//KERGUELEN_
            {300.8017, 6377304.063, -11, 851, 5, 0, 0, 0, 0},//KERTA_
            {294.9786982, 6378206.4, 42, 124, 147, 0, 0, 0, 0},//LCASTRO_

            {297.0, 6378388.0, -(float) 90.7, -(float) 106.1, -(float) 119.2, -4.09, -0.218, 1.05, -1.37},//KKJ_
            {293.465, 6378249.145, -90, 40, 88, 0, 0, 0, 0},//LIBER_
            {294.9786982, 6378206.4, -133, -77, -51, 0, 0, 0, 0},//LUZON_
            {299.15281285, 6377397.155, 639, 405, 60, 0, 0, 0, 0}, //MASSA_
            {293.465, 6378249.145, 31, 146, 47, 0, 0, 0, 0},//MERCH_
            {293.465, 6378249.145, -92, -93, 122, 0, 0, 0, 0},//MINNA_
            {299.15281285, 6377397.155, 0, 0, 0, 0, 0, 0, 0}, //MONTJ_
            {294.9786982, 6378206.4, -8, 160, 176, 0, 0, 0, 0},//NAD27_
            {298.257222101, 6378137.0, (float) -0.9991, (float) 1.9048, (float) 0.519, -0.02625, -0.005641, -0.011344, -0.00028},//NAD83_
            {293.465, 6378249.145, -247, -148, 369, 0, 0, 0, 0},//NAHRW_

            {298.3, 6378200.0, -130, 110, -13, 0, 0, 0, 0},//OEGYP_
            {294.9786982, 6378206.4, 61, -285, -181, 0, 0, 0, 0},//OH_HAW_
            {294.9786982, 6378206.4, 45, -290, -172, 0, 0, 0, 0},//OH_KAU_
            {294.9786982, 6378206.4, 65, -290, -190, 0, 0, 0, 0},//OH_MAU_
            {294.9786982, 6378206.4, 56, -284, -181, 0, 0, 0, 0},//OH_OAH_
            {293.465, 6378249.145, -346, -1, 224, 0, 0, 0, 0},//OMAN_
            {297.0, 6378388.0, 185, 165, 42, 0, 0, 0, 0},//PITCA_
            {297.0, 6378388.0, -288, 175, -376, 0, 0, 0, 0}, // PROVI_
            {297.0, 6378388.0, -128, -283, 22, 0, 0, 0, 0},//QATAR_
            {297.0, 6378388.0, 164, 138, -189, 0, 0, 0, 0},//QORNO_

            {299.15281285, 6377397.155, (float) 419.3836, (float) 99.3335, (float) 591.3451, -0.850389, -1.817277, 7.862238, 0.99496},  //RT90_
            {298.25, 6378160.0, -57, 1, -41, 0, 0, 0, 0},//SAM69_
            {297.0, 6378388.0, -97, -88, -135, 0, 0, 0, 0},//SICIL_
            {293.465, 6378249.145, 0, 0, 0, 0, 0, 0, 0},//SIERR_
            {299.15281285, 6377397.155, 616, 97, -251, 0, 0, 0, 0},//SCHWA_
            {298.3, 6378155.000, 7, -10, -26, 0, 0, 0, 0},//SOUTHASIA_
            {298.257222101, 6378137.0, 0, 0, 0, 0, 0, 0, 0},//SWEREF99_
            {299.15281285, 6377397.155, (float) 660.077, (float) 13.551, (float) 369.344, 0.804816, 0.577692, 0.952236, -5.66},  //SWISS_
            {297.0, 6378388.0, -189, -242, -91, 0, 0, 0, 0},//TANAN_
            {300.8017, 6377276.34518, -689, 691, -46, 0, 0, 0, 0},//TIMBA_

            {299.15281285, 6377397.155, -148, 507, 685, 0, 0, 0, 0},  //TOKYO_
            {293.465, 6378249.145, -249, -156, 381, 0, 0, 0, 0},//UAE_
            {293.465, 6378249.145, 0, 0, 0, 0, 0, 0, 0},//VOIRO_
            {298.26, 6378135.0, 0, 0, 4, 0, 0, 0, 0},//WGS72_
            {297.0, 6378388.0, -155, 171, 37, 0, 0, 0, 0},//YACAR_
            {297.0, 6378388.0, -265, 120, -358, 0, 0, 0, 0},//ZANDE_
            {294.9786982, 6378206.4, -127.62153, -67.2434, -47.04738, 3.068038, -4.902977, -1.578073, -1.06002112},//PRS92_
            {299.3249646, 6377563.396, 375, -111, 431, 0, 0, 0, 0},//OSGB36
    };

}
